export default class KapcsolatPopupController {
constructor(kapcsolatService, $scope) {
'ngInject';
this._kapcsolatService = kapcsolatService;
this._$scope = $scope;
this.bevetelek = [
'0-50 M Ft-ig',
'50-100 M Ft-ig',
'100-500 M Ft-ig'
];
this.model = {
ceg: false
};
this._$scope.$watch('$ctrl.kivalasztottSzolgaltatasok', () => {
this.model.szolgaltatas = [];
angular.forEach(this.kivalasztottSzolgaltatasok, (value, key) => {
if (value) {
this.model.szolgaltatas.push(key);
}
});
}, true);
this._$scope.$watch('$ctrl.model.ceg', (newVal) => {
if (newVal) {
this.model.nev = '';
} else {
this.model.cegNev = '';
}
});
this._getSzolgaltatasok();
this.captchaUrl = this._getCaptchaUrl();
}
_getSzolgaltatasok() {
this._kapcsolatService.getSzolgaltatasok().then((response) => {
this.szolgaltatasok = response;
}, () => {
this.technikaiHiba = true;
});
}
getVarosokByIrszam() {
this._kapcsolatService.getVarosokByIrszam(this.model.iranyitoszam).then((response) => {
this.varosok = response;
if (this.varosok.length==1) {
this.model.varos = this.varosok[0];
} else {
this.model.varos = '';
}
}, () => {
this.technikaiHiba = true;
});
}
kuldes(e) {
e.preventDefault();
this._kapcsolatService.kuldes(this.model, this.captcha).then(() => {
this._captchaFrissites();
this.captcha = '';
this.success = true;
}, (err) => {
if (err.status && err.status == 400 && err.data && err.data.errors) {
this.errors = err.data.errors;
} else {
this.technikaiHiba = true;
}
this._captchaFrissites();
this.captcha = '';
});
}
_captchaFrissites() {
this.captchaUrl = this._getCaptchaUrl();
}
_getCaptchaUrl() {
return this._kapcsolatService.getCaptchaUrl();
}
}
|